package com.zhiyou.serviceImpl;

import com.zhiyou.dao.RepairDao;
import com.zhiyou.daoImpl.RepairDaoImpl;
import com.zhiyou.model.Repair;
import com.zhiyou.service.RepairService;
import com.zhiyou.util.PageBean;

public class RepairServiceImpl implements RepairService {

	@Override
	public PageBean<Repair> show(int pc, int ps) {
		RepairDao repairDao = new RepairDaoImpl();
		PageBean<Repair> pb = repairDao.findAll(pc, ps);
		return pb;
	}

	@Override
	public Repair find(int id) {
		// TODO Auto-generated method stub
		RepairDao repairDao = new RepairDaoImpl();
		Repair repair = repairDao.findById(id);
		return repair;
	}

	@Override
	public boolean delete(int id) {
		RepairDao repairDao = new RepairDaoImpl();
		boolean flag = repairDao.delete(id);
		return flag;
	}

	@Override
	public boolean update(Repair repair) {
		RepairDao repairDao = new RepairDaoImpl();
		boolean flag = repairDao.update(repair);
		return flag;
	}

	@Override
	public boolean add(Repair repair) {
		RepairDao repairDao = new RepairDaoImpl();
		boolean flag = repairDao.add(repair);
		return flag;
	}

	@Override
	public boolean dels(int[] id) {
		// TODO Auto-generated method stub
		RepairDao repairDao = new RepairDaoImpl();
		int id1[] = repairDao.dels(id);
		for(int i = 0;i<id1.length;i++){
			if(id1[i] == 0){
				return false;
			}
		}
		return true;
	}

	@Override
	public PageBean<Repair> find(String flat, String lo, int pc, int ps) {
		RepairDao repairDao = new RepairDaoImpl();
		PageBean<Repair> pb = repairDao.find(flat, lo, pc, ps);
		return pb;
	}
	
	
}
